package com.yh.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yh.bean.Inorder;
import com.yh.serviceImpl.InorderServiceImpl;

//订单
@Controller
public class InorderController {
	@Autowired
	private InorderServiceImpl  InorderServiceImpl;
	
	@RequestMapping("/addInorder")
	public String addInorder(Inorder in){	
		System.out.println("出售出售出售出售出售"+in);
		  Date date=new Date();		  
		  String code="";
		    Random rand=new Random();//生成随机数
		    for(int a=0;a<6;a++){
		    code+=rand.nextInt(10);//生成6位验证码
		      }			   
		    SimpleDateFormat sdf=new SimpleDateFormat("YYYYMMddhhmmss");		  
		  	String inonum = sdf.format(date).toString()+code;
		  	in.setInonum(inonum);
		   InorderServiceImpl.addInorder(in);		
		    return "../index";		    
		    }	
	
	
	@RequestMapping("/loadInorder")
	@ResponseBody
	public Map<?,?> loadInorder(int currentPage){
		Map<?,?> map=InorderServiceImpl.loadInoder(currentPage);	
		return map;
	}
}	

